• Fetching deploy tasks in iPXE Menu

    Unsolved FOG Problems
    2
    0 Votes
    2 Posts
    385 Views
    george1421G

    @kbats183 I haven’t looked at the quick registration bit of code but I did have a hack that updated the fog.auto.reg (full registration) option to begin imaging right after registration without a reboot. This involved taking the FOG supplied script updating it to your requirements and then adding a bit of code onto the end and then finally dynamically patching that script on every boot of the target system. It sounds like a lot of steps and its complicated but not if you know how fog works.

    I should be able to point you in a direction so you can get started.

    When FOG Linux (the os that gets transferred to the target computer for imaging) boots it runs the master fog script stored in the /bin directory in FOS Linux. The scripts bits of that /bin directory is here: https://github.com/FOGProject/fos/tree/master/Buildroot/board/FOG/FOS/rootfs_overlay/bin The file you are interested in is called fog.auto.reg. If you can understand bash script programming you can modify this file to fit your requirements. Once you have the script the way you need it then you can dynamically patch when FOS linux boots using this tutorial (understand this tutorial is for patching fog.man.reg but the concenpt is the same only the file name changes.

    https://forums.fogproject.org/topic/13500/dynamically-patching-fos-using-a-postinit-script

    I have tutorials that are targeting the manual registration but the concepts are similar. (hint: this is where I tweak the script to give me a custom calculated host name kind of like the auto naming but better. )
    https://forums.fogproject.org/topic/14278/creating-custom-hostname-default-for-fog-man-reg

    So that’s the background, how do I make it image right after rebooting?
    For the fog.man.reg file you append a bit of code that makes the script think the system rebooted and collects the latest imaging info.
    (For the life of me I can’t find that tutorial I created but here is the script that I collected from a recent issue with the code in the script.

    sysuuid=$(dmidecode -s system-uuid) sysuuid=${sysuuid,,}switch mac=$(getMACAddresses) base64mac=$(echo $mac | base64) token=$(curl -Lks --data "mac=$base64mac" "${web}status/hostgetkey.php") curl -Lks -o /tmp/hinfo.txt --data "sysuuid=${sysuuid}&mac=$mac&hosttoken=${token}" "${web}service/hostinfo.php" -A '' curl -Lks -o /tmp/hinfo.txt --data "sysuuid=${sysuuid}&mac=$mac" "${web}service/hostinfo.php" -A '' [[ -f /tmp/hinfo.txt ]] && . /tmp/hinfo.txt . /bin/fog.download

    In the case of fog.man.reg this code would be added at the very end of the script.

    Looking at the fog.auto.reg script I would say it should go at the very end of that script too.

    ref: https://forums.fogproject.org/topic/17601/deploy-image-right-after-registration-without-a-reboot/3
    ref: https://forums.fogproject.org/topic/16378/start-imaging-right-after-the-full-host-registration-without-reboot-possible

  • ipxe menu and image storage

    General
    7
    0 Votes
    7 Posts
    2k Views
    george1421G

    @kgosset Well I’m a strong believer of you learn more from your mistakes than your successes, so I’ll only give you a push in a direction.

    So lets take a hacker’s approach to this (the 1980s definition of a hacker not the 2000s blackhat).

    I already gave you one clue. Point your browser to http://<fog_server_ip>/fog/service/ipxe/boot.php?mac=00:00:00:00:00:00 That will display the FOG iPXE menu as the FOG Project developer (wizards) have create. I figure they know a lot more than I do about the iPXE menu commands and structure. So copy the contents of that menu save it into a text file (save yourself some grief by using notepad++ and not ms windows notepad to edit this file). Save the file as a UNIX script file and name it something like custommenu.ipxe. The ipxe extension is important.

    Now you can throw out a lot in this menu, but look for a :Menu line label. Delete the content below (but leave :Menu) down to :bootme (leave :bootme)

    Now insert this into the deleted section (between :Menu and :bootme)

    NOTE: this has NOT been tested. I only dreamed it up moments ago

    menu item fog.mainmenu Return to the FOG iPXE menu item --gap menu --name dell-laptop Dell Laptops item fog.dell.7400 Dell Latitude 7400 item --gap menu --name dell-desktop Dell Desktops item fog.dell.3060 Dell Optiplex 3060 (mini) item --gap menu --name utilities item fog.mdt Boot into MDT choose --default fog.mainmenu --timeout 10000 target && goto ${target} :fog.mainmenu params param mac0 ${net0/mac} param arch ${arch} param platform ${platform} param product ${product} param manufacturer ${product} param ipxever ${version} param filename ${filename} param sysuuid ${uuid} chain http://${boot-url}/service/ipxe/boot.php##params boot || goto MENU :fog.dell.7400 boot || goto MENU :fog.dell.3060 boot || goto MENU :fog.mdt mdt.1903 kernel http://${fog-ip}/wimboot imgfetch --name BCD http://${fog-ip}/mdt/Boot/BCD BCD imgfetch --name boot.sdi http://${fog-ip}/mdt/Boot/boot.sdi boot.sdi imgfetch --name boot.wim http://${fog-ip}/mdt/Sources/Boot.wim boot.wim boot || goto MENU

    Place this file on the FOG server in the /tftpboot directory.

    Now you need to make a new iPXE menu entry to call this menu.

    Menu Item: fog.CustomMenu
    Description: Custom FOG Menu
    Parameters:
    chain tftp://${fog-ip}/custommenu.ipxe
    boot || goto MENU

    Now pxe boot a target computer. See if your menu works to go into and out of the custom menu. I’ll say this again, I did not test this menu design so there are probably bugs in it. But this is the framework. Once your menu works then we can work on filling out the menu items in your custom menu. I will show you how to get the details for the menu items.

    ref:

    Contents of /tftpboot/default.ipxe https://forums.fogproject.org/topic/10944/using-fog-to-pxe-boot-into-your-favorite-installer-images https://ipxe.org/cmd/menu